<!DOCTYPE html>
<html>
<head>
<base href="${basePath}">
<meta charset="UTF-8">
<title>活动</title> $!{include("import_js_css.html")}
$!{include("import_tab_switch.html")}
</head>
<body>
	$!{include("header.html")}
	<div class="container menu_all">
		<div id="div_ul_tab" class="tabbable tabs-left panel-db-cdt">
			$!{include("tab.html")}
			<div class="tab-content panel-radius-search-all panel-search ">
				<div class="tab-pane active panel-search-cdts" id="panel-club">
						<form name="liftclubForm" role="form" class="form-horizontal"
							action="yueyogaAdmin/searchLiftClubs.jhtml" method="post">
							<div class="form-group">
								<label for="inputName" class="col-sm-1 control-label">主题</label>
								<div class="col-sm-3">
									<input type="text" class="form-control" name="name"
										id="inputName" value="${clubName}">
								</div>
								<label for="inputLiftClubState" class="col-sm-1 control-label">状态</label>
								<div class="col-sm-3">
									<select id="inputLiftClubState" data-live-search="true"
										class="selectpicker show-tick" data-width="100%"
										name="LiftClubState">
										<option value=""> </option>
										<option value="">全部</option>
										<option value="0">准备中</option>
										<option value="1">进行中</option>
										<option value="2">活动结束</option>
										<option value="3">活动取消</option>
									</select>
								</div>
								<br /> <br />
 								<label for="inputResponsible"
									class="col-sm-1 control-label">负责人</label>
								<div class="col-sm-3">
									<select id="inputResponsible" data-live-search="true"
										class="selectpicker show-tick" data-width="100%"
										name="responsibleId">
										<option value=""> </option>
										<option value="">全部</option>
										<!-- #foreach(GroupUserModel responsible : responsibles) -->
										<option value="${responsible.id}">${responsible.name}</option>
										<!-- #end -->
									</select>
								</div>
								<label for="inputPlacement" class="col-sm-1 control-label">场地</label>
								<div class="col-sm-3">
									<select id="inputPlacement" data-live-search="true"
										class="selectpicker show-tick" data-width="100%"
										name="placename">
										<option value=""> </option>
										<option value="">全部</option>
										<!-- #foreach(Place place : plPlace) -->
										<option value="${place.id}">${place.name}</option>
										<!-- #end -->
									</select>
								</div>
								<br /> <br /> <label for="inputCoach0"
									class="col-sm-1 control-label">老师</label>
								<div class="col-sm-3">
									<select id="inputCoach0" data-live-search="true"
										class="selectpicker show-tick" data-width="100%"
										name="coachType0Id">
										<option value=""> </option>
										<option value="">全部</option>
										<!-- #foreach(Coach ch0 : listCoach0) -->
										<option value="${ch0.coachId}">${ch0.name}</option>
										<!-- #end -->
									</select>
								</div>
								<label for="inputCoach1" class="col-sm-1 control-label">助教</label>
								<div class="col-sm-3">
									<select id="inputCoach1" data-live-search="true"
										class="selectpicker show-tick" data-width="100%"
										name="coachType1Id">
										<option value=""> </option>
										<option value="">全部</option>
										<!-- #foreach(Coach ch1 : listCoach1) -->
										<option value="${ch1.coachId}">${ch1.name}</option>
										<!-- #end -->
									</select>
								</div>
								<br /> <br />
								<br /> <br /> <label for="inputStartDate1"
									class="col-sm-1 control-label">起始时间</label>
								<div class="col-sm-3">
									<div id="inputStartDate1" class="input-group date"
										data-date-format="YYYY-MM-DD HH:mm">
										<input id="inputStart1" name="startdate1" type='text' class="form-control" />
										<span class="input-group-addon"><span
											class="glyphicon glyphicon-time"></span> </span>
									</div>
								</div>

								<label for="inputEndDate1" class="panel-searh-zhi">至</label>
								<div class="col-sm-3">
									<div id="inputEndDate1" class="input-group date"
										data-date-format="YYYY-MM-DD HH:mm">
										<input id="inputEnd1" name="enddate1" type='text' class="form-control" /> <span
											class="input-group-addon"><span
											class="glyphicon glyphicon-time"></span> </span>
									</div>
								</div>
								<br /> <br /> <label for="inputStartDate2"
									class="col-sm-1 control-label clear">结束时间</label>
								<div class="col-sm-3">
									<div id="inputStartDate2" class="input-group date"
										data-date-format="YYYY-MM-DD HH:mm">
										<input id="inputStart2" name="startdate2" type='text' class="form-control" />
										<span class="input-group-addon"><span
											class="glyphicon glyphicon-time"></span> </span>
									</div>
								</div>
								<label for="inputEndDate2" class="panel-searh-zhi">至</label>
								<div class="col-sm-3">
									<div id="inputEndDate2" class="input-group date"
										data-date-format="YYYY-MM-DD HH:mm">
										<input id="inputEnd2" name="enddate2" type='text' class="form-control" /> <span
											class="input-group-addon"><span
											class="glyphicon glyphicon-time"></span> </span>
									</div>
								</div>
								<input name="pageNo" type="hidden" value="1"> 
								<input name="display" type="hidden" value="block"><br /> <br />
								<div class="panel-db-search">
									<button type="submit" class="btn btn-ade-default">搜索</button>
								</div>
							</div>
						</form>
				</div>
			</div>
		</div>

		<!-- #if(isBlank == 'blank') -->
		<!-- #else -->
		<div class="div_search_result clear">
			<div class="panel-heading panel-result-title">
				<h3 class="panel-title">查询结果</h3>
				<div class="btn-group btn-gp-default">
					<button id="btn_add" type="button"
						class="btn btn-default panel-radius-left">添加</button>
					<button id="btn_edit" type="button"
						class="btn btn-default panel-radius-center">修改</button>
					<button id="btn_delete" type="button"
						class="btn btn-default panel-radius-center">删除</button>
					<button id="btn_export" type="button"
						class="btn btn-default panel-radius-right">导出</button>
				</div>
			</div>
			$!{include("liftclub_list.html")}
		</div>
		<!-- #end -->
	</div>
</body>
</html>
<script type="text/javascript">
	function documentReady() {
		var msg = "${msg}";
		if (msg) {
			alert(msg);
		}
	}
	$(function() {
		$(".div_search_result").hide();
		 var display = "${display}";
		if(display=='block'){
			$(".div_search_result").show();
		}
		
		$("#inputStartDate1").datetimepicker({
			language : "zh-CN"
		});
		
		$("#inputEndDate1").datetimepicker({
			language : "zh-CN"
		});
		
		$("#inputStartDate2").datetimepicker({
			language : "zh-CN"
		});
		$("#inputEndDate2").datetimepicker({
			language : "zh-CN"
		});

		
		$("#inputStartDate1").on("dp.change", function(e) {
			$("#inputEndDate1").data("DateTimePicker").setMinDate(e.date);
		});

		$("#inputEndDate1").on("dp.change", function(e) {
			$("#inputStartDate1").data("DateTimePicker").setMaxDate(e.date);
		});
		
		$("#inputStartDate2").on("dp.change", function(e) {
			$("#inputEndDate2").data("DateTimePicker").setMinDate(e.date);
		});

		$("#inputEndDate2").on("dp.change", function(e) {
			$("#inputStartDate2").data("DateTimePicker").setMaxDate(e.date);
		});
		
		//去掉下拉输入框
		$("#inputLiftClubState").select2({
			width: "100%",
			minimumResultsForSearch: -1
		});

		//查询条件回显
		$("#inputName").select2("val", "${name}");
		$("#inputLiftClubState").select2("val", "${LiftClubState}");
		$("#inputCoach0").select2("val", "${coachType0Id}");
		$("#inputCoach1").select2("val", "${coachType1Id}");
		$("#inputResponsible").select2("val", "${responsibleId}");
		$("#inputPlacement").select2("val", "${placename}");
		$("#inputStart1").select2("val", "${startdate1}");
		$("#inputEnd1").select2("val", "${enddate1}");
		$("#inputStart2").select2("val", "${startdate2}");
		$("#inputEnd2").select2("val", "${enddate2}");

		//全选反选
		$("#chkallIds").click(
				function() {
					$(":input[name='chk_name']").prop("checked",
							$(this).prop("checked"));
				});
		//添加
		$("#btn_add").click(function() {
			window.location.href = "yueyogaAdmin/toAddLiftClubs.jhtml";
		});

		//修改
		$("#btn_edit")
				.click(function() {
							var chks = $('input[name="chk_name"]:checked');
							if (chks.length == 1) {
								window.location.href = "yueyogaAdmin/toUpdateLiftClub.jhtml?id="
										+ chks.val();
							} else {
								alert("请选择一条记录进行修改");
							}
						});

		//删除
		$("#btn_delete").click(function() {
			var chks = $('input[name="chk_name"]:checked');
			if (chks.length > 0) {
				confirm("确定要删除吗", function() {
					this.close();
					var url = "yueyogaAdmin/deleteLiftClub.jhtml";
					var d = wait("正在删除，请稍候...");

					var ids = [];
					chks.each(function(index, item) {
						ids.push($(item).val());
					});

					$.post(url, {
						"ids" : ids
					}, function(msg) {
						if (msg == "success") {
							d.content("删除成功");
							setTimeout(function() {
								d.close().remove();
								$(':input[name="chk_name"]').prop("checked",false);
								document.liftclubForm.submit();
							}, 300);
						} else {
							error("删除失败");
						}
					});
				});
			} else {
				alert("请选择要删除的记录");
				d.close();
			}
		});
	   //导出活动
	   $("#btn_export").click(function(){
		    var action = "yueyogaAdmin/exportliftclubInfo.jhtml";
			var oldAction = $("form[name='liftclubForm']").prop("action");
			$("form[name='liftclubForm']").prop("action",action);
			$("form[name='liftclubForm']").submit();
			$("form[name='liftclubForm']").prop("action",oldAction);
	   });
	   
	});
	
</script>